# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=qemu

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"

pkgver=2.0.0
pkgrel=1
pkgdesc="A generic and open source processor emulator (mingw-w64)"
arch=('any')
license=('GPL2' 'LGPL2')
url="http://wiki.qemu.org/Index.html"
makedepends=('perl' 'python2' 'bison')
depends=("${MINGW_PACKAGE_PREFIX}-libjpeg" "${MINGW_PACKAGE_PREFIX}-libpng" "${MINGW_PACKAGE_PREFIX}-libssh2" 
         "${MINGW_PACKAGE_PREFIX}-SDL2" "${MINGW_PACKAGE_PREFIX}-curl" "${MINGW_PACKAGE_PREFIX}-openssl")
source=(http://wiki.qemu.org/download/${_realname}-${pkgver}.tar.bz2)
md5sums=('SKIP')
options=('!strip' 'debug')

build() {

  export CC=${MINGW_PREFIX}/bin/gcc
  export CXX=${MINGW_PREFIX}/bin/g++

  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  declare -a extra_config
  if check_option "strip" "n"; then
    extra_config+=("--disable-strip")
  fi

  ${srcdir}/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host-cc=$CC \
    --python=/usr/bin/python2 \
    --datadir=${MINGW_PREFIX}/etc/qemu \
    --mandir=${MINGW_PREFIX}/share/qemu \
    --bindir=${MINGW_PREFIX}/bin \
    --libdir=${MINGW_PREFIX}/lib \
    --sysconfdir=${MINGW_PREFIX}/etc/qemu \
    --disable-docs \
    --disable-gtk \
    --disable-xen \
    --enable-libssh2 \
    --disable-kvm \
    --disable-bluez \
    --disable-spice \
    --target-list=x86_64-softmmu,arm-softmmu,i386-softmmu \
    "${extra_config[@]}"

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="${pkgdir}" install
}
